#include <iostream>
#include <string>
#include <memory>
using namespace std;
class Fruit
{
public:
    Fruit() {}
    virtual void show() = 0;
};
class Apple :public Fruit
{
public:
    Apple() {}
    virtual void show()
    {
        cout << "apple()" << endl;
    }
};

class Pear :public Fruit
{
public:
    Pear() {}
    virtual void show()
    {
        cout << "Pear" << endl;
    }
};
class Nut :public Fruit{
public:
    Nut() {}
    virtual void show()
    {
        cout << "Nut()" << endl;
    }
};

class FruitFactory
{
public:
    static shared_ptr<Fruit> Creat(const string& name)
    {
        if(name == "Apple")
            return shared_ptr<Apple>();
        else if(name == "Pear")
            return shared_ptr<Pear>();
        else if(name == "Nut")  
           return shared_ptr<Nut>();
        else
            return shared_ptr<Fruit>();
    }
};
int main()
{
    //FruitFactory a;
    // string s = "Apple";
    // a.Creat(s)->show();
    // a.Creat(move("Pear"))->show();
    shared_ptr<Fruit> fruit = FruitFactory::Creat("Nut");
    fruit->show();
    // shared_ptr<int> ms(new int(10));
    // cout << ms << endl;
    return 0;
}